/**
 * Created by gengrong on 16/4/18.
 */
import { getFetchStatus } from 'actions/util';
import * as ReactRedux from 'react-redux';
import * as React from 'react';
import PureRunnableGroupManageList from '../components/runnable-group-manage-list'
import * as RunnableGroupAction from 'actions/runnable-group';

const mapStateToProps = (state) => {
  return {
    isFetching: getFetchStatus(state, RunnableGroupAction.search),
    users: state.runnableGroupList
  };
};

const mapDispatchToProps = (dispatch) => {
  return {
    initFetch: () => {
      return dispatch(RunnableGroupAction.search());
    },
    onSearchSubmit: (query) => {
      return dispatch(RunnableGroupAction.search(query));
    },
    onSaveRunnableGroup: (runnableGroup) => {
      return dispatch(RunnableGroupAction.create(runnableGroup));
    }
  };
};

class RunnableGroupManageList extends React.Component {
  componentDidMount() {
    this.props.initFetch();
  }

  render() {
    return <PureRunnableGroupManageList {...this.props}/>;
  }
}

export default ReactRedux.connect(mapStateToProps, mapDispatchToProps)(RunnableGroupManageList);
